#ifndef _TEXTBOX_H_
#define _TEXTBOX_H_
#pragma once
#include "SDL.h"
#include "SDL_draw.h"
#include "SDL_ttf.h" 
#include "string"
#define TAM_FONT 18
//Space between last character rendered and end of textbox, 
//values over or equal to 5 recommended.
#define END_SPACE 5
//Space between first character rendered and beginning of textbox, 
//values over or equal to 5 recommended.
#define BEGIN_SPACE 5
//Colors
#define CYAN 0x99FFCC
#define BLACK 0x000000
#define WHITE 0xFFFFFF

class Textbox {
private:
	SDL_Rect box;
    SDL_Surface* screen;
    TTF_Font* font;
    SDL_Color textColor;
	int textWidth;
    bool active, cursor;
	bool selected;
    std::string showText;
public:
	Textbox(SDL_Surface* screen, int posX, int posY, int width, int height);
	Textbox(SDL_Surface* screen, int posX, int posY, int width, int height, std::string text);
	/**
	Renderizes the text.
	**/
	bool drawText(void);
	
	/**
	According to the event received sets to show the character
	for the button pressed or gets active by getting clicked.
	**/
	void handleEvent(SDL_Event* event);

	/**
	Modifies value of selected attribute.
	**/
	void setSelected(bool select);
	/**
	Draws a blank box.
	**/
	bool drawBox(void);
	/**
	Draws the textbox.
	**/
	bool draw(void);
	/**
	Sets the text received as the content of the textbox.
	**/
	void setText(std::string t);
	/**
	Returns the textcontained in the textbox.
	**/
	std::string getText(void);
	/**
	Vacia la caja
	**/
	void clearBox();
	/**
	Draws cursor.
	**/
	void drawCursor(int pos);
	/**
	Verifica que se hizo click en la caja.
	**/
	bool isClicked(SDL_Event* event);
	~Textbox(void);

};
#endif
